package Serveur;

import org.omg.CORBA.ORB;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;

import BanqueGestion.BanqueImpl;


public class ServeurBanque {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {

		ORB orb = ORB.init(args, null);
		POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

		BanqueImpl impl1 = new BanqueImpl();
		BanqueImpl impl2 = new BanqueImpl();

		byte[] id1 = rootPOA.activate_object(impl1);
		byte[] id2 = rootPOA.activate_object(impl2);
		org.omg.CORBA.Object ref1 = rootPOA.id_to_reference(id1);
		org.omg.CORBA.Object ref2 = rootPOA.id_to_reference(id2);
		

		NamingContextExt context = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));

		context.rebind(context.to_name("A"), ref1);
		context.rebind(context.to_name("B"), ref2);
		
		rootPOA.the_POAManager().activate();
		orb.run();
	}

}
